1. Field of the Invention
The present invention relates to file systems that are accessible across computer networks. More particularly, the present invention relates to a method and an apparatus for reducing network traffic for append operations to files that are located on a remote file server. This method and apparatus operates by keeping track of file append operations on a local computer system when possible instead of always communicating with the remote file server.
2. Related Art
As computer networks are increasingly used to link computer systems together, distributed operating systems have been developed to control interactions between computer systems across a computer network. Some distributed operating systems allow client computer systems to access resources on server computer systems. For example, a client computer system may be able to access a file on a server computer system across a network. Such distributed file systems make it easy to manipulate files located on a remote server. However, if such distributed file systems are not designed carefully, they can easily generate unnecessary communications across the network, which can degrade overall system performance.
Unnecessary network data transfers are often generated when an application appends data to a file located on a remote file server. For example, many applications continually append data to a log file. If the application is located on a client and the log file is located on a remote file server, each time data is appended to the log file, a packet is sent across the network to transfer data to the remote file server and another packet is returned to confirm that the data was received. These packets consume valuable network bandwidth and cause corresponding interrupts on the client in order to process the packets. These interrupts are time-consuming for an application on the client, because the application must typically save state in order to service each interrupt.
Note that most of this overhead is wasted because append operations commonly involve only a small amount of data. For example, if each append operation involves about 100 bytes of data, and each packet can transfer about 1000 bytes of data, the application generates ten packets to transfer an amount of data that could have been transferred in a single packet. Also suppose that each append operation generates a disk access on the file server to commit the data to non-volatile storage. If the disk block size is 8 K bytes, then the application generates 80 disk accesses to write an amount of data to disk that could have been written to the disk in a single access.
What is needed is a method and apparatus for accessing a file located on a remote server that does not generate unnecessary overhead in appending small amounts of data to a file.
One embodiment of the present invention provides a system that reduces network traffic and other system overhead for remote file append operations. This system operates by keeping track of file append operations on a local computer system when possible instead of always communicating with a remote file server. More specifically, the system operates by receiving a request at the local computer system to append additional data to a file residing in non-volatile storage on the remote file server. If sufficient space has been allocated to accommodate the additional data on the remote file server, the system writes the additional data to the end of a locally cached copy of the file in the local computer system. Next, the system updates a file length value stored in the local computer system to reflect the additional data. If sufficient space has not been allocated to accommodate the additional data on the remote file server, the system requests additional space to be allocated past the end of the file on the remote file server. If the request is granted, the system updates an allocated space value for the file stored on the local computer system to reflect the additional space.
In one embodiment of the present invention, after writing the additional data to the end of a locally cached copy of the file in the local computer system, the system also updates the file length value stored on the local computer system to reflect the additional data.
In one embodiment of the present invention, the system propagates the additional data from the locally cached copy of the file to the non-volatile storage on the remote file server in a lazy manner. In a variation on the above embodiment, this propagation takes place during one of, an automatic periodic file system flush operation, a file synchronization operation, or a cache invalidation operation.
In one embodiment of the present invention, if the local computer system does not posses a write token allowing the local computer system to write to the file, the system requests the write token from the remote file server.
In one embodiment of the present invention, the additional space for the file is allocated in block-sized units that match a block size for the non-volatile storage, or that match a payload size for a network packet.
One embodiment of the present invention provides a system that reduces network traffic and other system overhead for remote file append operations. The system operates by receiving a request at the remote file server from a local computer system for additional space to be allocated past the end of a file residing in non-volatile storage on the remote file server. If sufficient space is available in the non-volatile storage, the system allocates and initializes the additional space. Next, the system informs the local computer system how much additional space was allocated so that the local computer system can update an allocated space value for the file stored on the local computer system. The system allows the local computer system to append data into the additional space without making requests to the remote file server. The system eventually receives data written into the addition space from the local computer system in a lazy manner. If sufficient space is not available in the non-volatile storage, the system informs the local computer system that the additional space cannot be allocated.
In one embodiment of the present invention, the system receives a request at the remote file server for a token for the file from a second client. This token allows a holder of the token to read from the file if the token is a read token and to write to the file if the token is a write token. If the local computer system holds the write token for the file, the system sends a request from the remote file server to the local computer system to invalidate the write token. This allows the local computer system to invalidate the write token. Next, the remote file server receives a file length value from the local computer system, and writes the file length value to the non-volatile storage. Finally, the system sends the requested token to the second client.
In a variation on the above embodiment, the local computer system invalidates the write token by downgrading the write token to a read token if the request from the second client is for a read token, and by invalidating the write token if the request from the second client is for the write token.